package cn.hquanheng.java_base.day08;

import java.util.Comparator;

public class Student implements Comparator {
	private String name;
	private double score;

	public Student() {}
	public Student(String name,double score) {
		this.name=name;
		this.score=score;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public double getScore() {
		return score;
	}
	public void setScore(double score) {
		this.score = score;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
	@Override
	public int compare(Object o1, Object o2) {
		return ((Student) o1).getScore()-((Student) o2).getScore()>0?1:-1;
	}
	public  int hashCode() {
		final int prime =31;
		int result =1;
		result = prime * result + ((name== null ) ? 0: name.hashCode());
		long temp;
		temp=Double.doubleToLongBits(score);
		result = prime * result + (int)(temp ^ (temp>>>32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if(this == obj)
			return true;
		if(obj == null)
			return false;
		if(getClass()!= obj.getClass())
			return false;
		return true;
	}
	
	
}
